<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

	<div class="ibox">
		<div class="ibox-content bodycss">
			<section class="panel panel-padding ">
				<div class="ibox-toolbar">
				</div>
				   <table id="menuTeble" lay-filter="popedomLay"></table>
			</section>
		</div>
	</div>
	<script type="text/javascript">
	 layui.config({base: "js/common/"}).use(["common", "element", "layer", "table", "jquery"], function(){
			var elem = layui.element;
			var layer = layui.layer;
			var table = layui.table;    
			var $ = layui.jquery;  
			layui.common.init();
			
			 table.render({	
				     elem: '#menuTeble'
				    ,height: 550
				    ,url: 'reservation/getTable.do?area_id=${area_id}&tmp=${tmp}'//数据接口
				    ,page: true //开启分页
				    ,cols: [[ //表头
				       {field: 'goods_id', title: '商品id', width:80,align:'center' },
				       {field:'goods_name', width:120,align:'center', title: "商品名称" },
				       {field:'common_price', width:120,align:'center', title: "销售价格" },
				       {field:'specifications', width:120,align:'center', title: "商品规格" },
				       {field:'goods_type', width:120,align:'center',title: "商品属性"},
				       {field:'goods_destine_quota', width:120,align:'center',title: "预定限额" },
				       {field:'goods_storage', width:120,align:'center',title: "库存数量" },
				       {field:'shipping_fee', width:120,align:'center',title: "商品运费" },
				       {field:'nomal', width:120,align:'center',title: "商品状态",templet:'#m_type' },
				       {fixed: 'right', width:350, align:'center', toolbar: '#popedomBar',title:"操作"}
				    ]]
				  });	
			//监听行事件
			table.on('tool(popedomLay)',function(obj){
				var data = obj.data;
				var even = obj.event;
				var id = data.goods_id;
				if(even == "delete"){//用来判断使用具体的哪一个事件
				layer.confirm('真的删除行么', function(index){
					$.ajax({
						url : "${pageContext.request.contextPath}/reservation/deleteMethod.do",
						method : "post",
						data : {
							"id" : id
						},
						success : function (json){
							if(json.statusCode == 200){
								layer.msg(json.message,{icon : 5, time : 2000})
								table.reload('#menuTeble')
							}else{
								layer.msg(json.message,{icon : 6, time : 2000})
							}
						}
					})
					obj.del();
					layer.close(index);
				});
				}else if(even == "checkd"){
						layer.open({
	                    type: 2,
	                    title: '修改用户信用信息',
	                    content: '${pageContext.request.contextPath}/reservation/toChec.do',
	                    area: ['650px', '600px'],
	                    anim: 5,
	                    isOutAnim: true,
	                    maxmin: true,
	                    resize: false,
	                    moveOut: true,
	                    zIndex: 99999,
	                    success: function(layero, index){
	                    	var body = layer.getChildFrame('body', index);
	                    	body.contents().find("INPUT[name='goodsId']").val(data.goods_id);
	                    	body.contents().find("INPUT[name='goods_name']").val(data.goods_name);
	                        body.contents().find("INPUT[name='common_price']").val(data.common_price);
	                        body.contents().find("INPUT[name='specifications']").val(data.specifications);
	                        body.contents().find("INPUT[name='goods_type']").val(data.goods_type);
	                        body.contents().find("INPUT[name='goods_destine_quota']").val(data.goods_destine_quota);
	                        body.contents().find("INPUT[name='goods_storage']").val(data.goods_storage);
	                    },
	                    end : function(){
	                    	table.reload("#popedomLay");
	                    }
			    	});
				}
			})
		});
</script>
<script type="text/html" id="m_type">	
	    {{#  if(d.nomal == "0") {  }}
			<font color="#00ff00">正品</font>
		{{#  } else if(d.nomal == "1") {  }}
			<font color="#ff0000">打折</font>
         {{#  } else if(d.nomal == "2") {  }}
			<font color="#ff0000">体验</font>
		{{#  } else if(d.nomal == "3") {  }}
			<font color="#ff0000">积分兑换</font>
		{{#  } else if(d.nomal == "4") {  }}
			<font color="#ff0000">用来打包</font>
		{{#  } else if(d.nomal == "7") {  }}
			<font color="#ff0000">可兑换打包品</font>
		{{#  }  }}
</script>
<script type="text/html" id="popedomBar">
		<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete" >删除</a>
		<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="checkd" >修改</a>
</script>
